﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Data.SqlClient;

namespace Pharmacy_management_system
{
    public partial class Form3 : Form
    {
        public Form3(string s)
        {
            InitializeComponent();
            dpp_dp_info(s);
        }

        private void radioButton5_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton5.Checked)
            {
                panel10.Enabled = false;
            }
        }

        private void radioButton6_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton6.Checked)
            {
                panel10.Enabled = true;
            }
        }
        private void dpp_dp_info(string a)
        {
            checkBox19.Checked = false; checkBox21.Checked = false; checkBox23.Checked = false; checkBox30.Checked = false; checkBox51.Checked = false;
            checkBox21.Checked = false; checkBox24.Checked = false; checkBox26.Checked = false; checkBox23.Checked = false; checkBox33.Checked = false;
            checkBox34.Checked = false; checkBox35.Checked = false; checkBox36.Checked = false; checkBox37.Checked = false; checkBox38.Checked = false;
            checkBox39.Checked = false; checkBox40.Checked = false; checkBox41.Checked = false; checkBox42.Checked = false; checkBox46.Checked = false;
            checkBox47.Checked = false; checkBox48.Checked = false; checkBox49.Checked = false; checkBox43.Checked = false; checkBox44.Checked = false;
            string myID;
            string dpp_allid = ",";
            myID = a;//获取当前选中的列。第一列
            SqlConnection con1 = new SqlConnection(SQL.constr);
            SqlConnection con2 = new SqlConnection(SQL.constr);
            con1.Open();
            con2.Open();
            string cmdText1 = "select  dpp_id from dpp_detail where  case_id='" + myID + "'";
            string cmdText2 = "select c_question from dpp_main where case_id='" + myID + "'";
            SqlCommand cmd1 = new SqlCommand(cmdText1, con1);
            SqlCommand cmd2 = new SqlCommand(cmdText2, con2);
            SqlDataReader dr1 = cmd1.ExecuteReader();
            SqlDataReader dr2 = cmd2.ExecuteReader();
            while (dr2.Read())
            {
                richTextBox13.Text = dr2[0].ToString();
            }
            while (dr1.Read())
            {
                dpp_allid = dpp_allid + dr1[0].ToString();
                dpp_allid = dpp_allid + ",";
            }
            dr2.Close();
            dr1.Close();
            con1.Close();
            con2.Close();
            if (dpp_allid.IndexOf(",1,") >= 0) { checkBox19.Checked = true; }
            if (dpp_allid.IndexOf(",2,") >= 0) { checkBox21.Checked = true; }
            if (dpp_allid.IndexOf(",3,") >= 0) { checkBox23.Checked = true; }
            if (dpp_allid.IndexOf(",5,") >= 0) { checkBox30.Checked = true; }
            if (dpp_allid.IndexOf(",6,") >= 0) { checkBox51.Checked = true; }
            if (dpp_allid.IndexOf(",7,") >= 0) { checkBox21.Checked = true; }
            if (dpp_allid.IndexOf(",8,") >= 0) { checkBox24.Checked = true; }
            if (dpp_allid.IndexOf(",9,") >= 0) { checkBox26.Checked = true; }
            if (dpp_allid.IndexOf(",10,") >= 0) { checkBox23.Checked = true; }
            if (dpp_allid.IndexOf(",11,") >= 0) { checkBox33.Checked = true; }
            if (dpp_allid.IndexOf(",12,") >= 0) { checkBox34.Checked = true; }
            if (dpp_allid.IndexOf(",13,") >= 0) { checkBox35.Checked = true; }
            if (dpp_allid.IndexOf(",14,") >= 0) { checkBox36.Checked = true; }
            if (dpp_allid.IndexOf(",17,") >= 0) { checkBox37.Checked = true; }
            if (dpp_allid.IndexOf(",18,") >= 0) { checkBox38.Checked = true; }
            if (dpp_allid.IndexOf(",19,") >= 0) { checkBox39.Checked = true; }
            if (dpp_allid.IndexOf(",20,") >= 0) { checkBox40.Checked = true; }
            if (dpp_allid.IndexOf(",21,") >= 0) { checkBox41.Checked = true; }
            if (dpp_allid.IndexOf(",22,") >= 0) { checkBox42.Checked = true; }
            if (dpp_allid.IndexOf(",23,") >= 0) { checkBox46.Checked = true; }
            if (dpp_allid.IndexOf(",24,") >= 0) { checkBox47.Checked = true; }
            if (dpp_allid.IndexOf(",25,") >= 0) { checkBox48.Checked = true; }
            if (dpp_allid.IndexOf(",26,") >= 0) { checkBox49.Checked = true; }
            if (dpp_allid.IndexOf(",27,") >= 0) { checkBox43.Checked = true; }
            if (dpp_allid.IndexOf(",44,") >= 0) { checkBox44.Checked = true; }
        }
    }
}
